﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <style>
        /*表头居中*/
        th{
            text-align:center;
        }
        /*列居中*/
        td{
            text-align:center;
            width:200px;
        }
    </style>
    <asp:Button ID="btnAdd" runat="server" Text="添加商品" OnClick="btnAdd_Click" />
    <%--AutoGenerateColumns="false"为不自动增加列--%>
    <asp:GridView ID="gv1" runat="server" AutoGenerateColumns="false" OnRowEditing="gv1_RowEditing" OnRowDeleting="gv1_RowDeleting" OnRowUpdating="gv1_RowUpdating" OnRowCancelingEdit="gv1_RowCancelingEdit">
        <Columns>
            <%--BoundField为要绑定的数据库字段 DataField为数据字段--%>
            <asp:BoundField DataField="Id" HeaderText="ID" ReadOnly="true" />
            <asp:BoundField DataField="ProId" HeaderText="商品编号" />
            <asp:BoundField DataField="ProName" HeaderText="商品名称" />
            <asp:BoundField DataField="Price" HeaderText="商品价格" />
            <asp:BoundField DataField="Stock" HeaderText="商品库存" />
            <asp:CommandField ShowEditButton="true" ShowDeleteButton="true" HeaderText="操作"/>
        </Columns>
    </asp:GridView>

</asp:Content>
